package com.jxb.redisLimit;

import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.slot.GatewayFlowSlot;
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import reactor.core.publisher.Mono;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/10/21 21:59
 **/
//@Configuration
public class RedisLimitConfig {

    @Bean
    KeyResolver keyResolver() {
        //url限流
        // return exchange -> Mono.just(exchange.getRequest().getURI().getPath());
        //参数限流
        return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("user"));
    }

}
